<?php
/**
 * [商网通 System] Copyright swtshop.cn
 * QQ: 1170787711
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied');
class design_uqcms extends control
{
    function __construct()
    {
        $this->spid = $_SESSION['shop']['spid'];
        parent::__construct();
    }
    public function index()
    {
        $row = $this->db->get_one("select * from " . table('shop_design') . " where shop_id = " . $this->spid);
        if ($row['id']) {
            $this->assign('row', $row);
        } else {
            $this->db->add(table('shop_design'), array('shop_id' => $this->spid));
        }
        $this->display();
    }
    function save()
    {
        if ($_POST) {
            $setsql['top_images'] = P('top_images');
            $setsql['bg_images'] = P('bg_images');
            $query = $this->db->update(table('shop_design'), $setsql, 'shop_id = ' . $this->spid);
            if ($query) {
                right_json();
            } else {
                error_json('保存失败');
            }
        } else {
            error_json('提交错误');
        }
    }
}